package helper;


import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.http.HttpServletRequest;

import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.springframework.context.support.ClassPathXmlApplicationContext;


import com.opensymphony.xwork2.ActionContext;
import com.sun.org.apache.bcel.internal.generic.NEW;




public class Test {
public static void main(String[] args) {
//	System.currentTimeMillis()
//	System.out.println(new SimpleDateFormat("dd天HH小时mm分").format(Long.valueOf(7*24*60*60*1000)+Long.valueOf("1270947687097")-System.currentTimeMillis()));
//	long temp7 = System.currentTimeMillis()+7*24*60*60*1000;
//	long temp = System.currentTimeMillis();
////	System.out.println(Calendar.getInstance().getTime());
////	Calendar.getInstance().gett
//	Date datea = java.sql.Date.valueOf("2010-04-25");
//	System.out.println((System.currentTimeMillis() - datea.getTime())/(3600*1000));
//	System.out.println((System.currentTimeMillis() - datea.getTime())/(3600*1000*7));
//	System.out.println(new SimpleDateFormat("dd").format( System.currentTimeMillis() +(7-1) * 24*60*60*1000-System.currentTimeMillis()));	//时间戳
//	System.out.println(new SimpleDateFormat("HH").format((System.currentTimeMillis() + 24*60*60*1000 - System.currentTimeMillis())-3600*8));
//	System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis()-(3600*60*60*24)));	//时间戳转换
//	System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis()-60*60*24*1000*5));
//	System.out.println(System.currentTimeMillis()-60*60*24*1000*5);
//	System.out.println(new SimpleDateFormat("dd HH:mm:ss").format(System.currentTimeMillis()+60*60*1000*5));
	

//	String a = "http://localhost:8080/c2c/show!toIndex.do?jSessionId=897159E854A6910AE11F13F7605A2F6E ";
//////	int aa = 
////	System.out.println(a.indexOf("/"));
////	System.out.println(a.lastIndexOf("/"));
//	Pattern pattern = Pattern.compile("(http://|https://){1}[\\w\\.\\-/:]+"); 
//
//	Matcher matcher = pattern.matcher(a); 
//
//	StringBuffer buffer = new StringBuffer(); 
//
//	while(matcher.find()){              
//
//	    buffer.append(
//	    		matcher.group());        
//
//	    buffer.append("\r\n");              
//
//	System.out.println(buffer.toString()); 
//
//	} 
	System.out.println(MD5Helper.enc(String.valueOf(new Random().nextDouble())));
//	ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:/");
	
}

/*
 * 获取真实的ip地址；
 */
	public String getIpAddr(HttpServletRequest request) {
		String ip = request.getHeader("x-forwarded-for");
		if(ip == null || ip.length() == 0 || "unknow".equalsIgnoreCase(ip)){
			ip = request.getHeader("Proxy-Click-IP");
		}
		if(ip == null || ip.length() == 0 || "unknow".equalsIgnoreCase(ip)){
			ip = request.getHeader("WL-Proxy-Click-IP");
		}
		if(ip == null || ip.length() == 0 || "unknow".equalsIgnoreCase(ip)){
			ip = request.getRemoteAddr();
		}
		return ip;
	}
}
